package com.qdu.hyy.PopularityCount;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableUtils;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class MovieCountRevenueWritable implements Writable {
    private IntWritable movieCount;
    private DoubleWritable revenue;

    public MovieCountRevenueWritable() {
        this.movieCount = new IntWritable();
        this.revenue = new DoubleWritable();
    }

    public MovieCountRevenueWritable(int movieCount, double revenue) {
        this.movieCount = new IntWritable(movieCount);
        this.revenue = new DoubleWritable(revenue);
    }

    // Getters and setters
    public IntWritable getMovieCount() {
        return movieCount;
    }

    public void setMovieCount(IntWritable movieCount) {
        this.movieCount = movieCount;
    }

    public DoubleWritable getRevenue() {
        return revenue;
    }

    public void setRevenue(DoubleWritable revenue) {
        this.revenue = revenue;
    }

    // Writable interface methods
    @Override
    public void write(DataOutput out) throws IOException {
        movieCount.write(out);
        revenue.write(out);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        movieCount.readFields(in);
        revenue.readFields(in);
    }
}